const userModel = require("../../models/sys/user");
const createToken = require("../../utils/jwt/createToken");
const authList = require("./data");

module.exports = {
  login(req, res) {
    const { username, pwd } = req.body;

    if (username === "admin" && pwd === "admin") {
      res.json({
        code: "200",
        msg: "ok",
        data: {
          username,
          userId: 1,
          token: 'token',
          // token: createToken({
          //   user: "admin",
          // }),
          authList: authList.admin,
        },
      });
    } else if (username === "user" && pwd === "user") {
      res.json({
        code: "200",
        msg: "ok",
        data: {
          username,
          userId: 2,
          token: 'token',
          // token: createToken({
          //   user: "user",
          // }),
          authList: authList.user,
        },
      });
    } else {
      res.json({
        code: "1001",
        msg: "账号或者密码错误",
      });
    }
  },
  refreshToken(req, res) {
    res.json({
      code: "200",
      msg: "ok",
      token: createToken({
        user: "admin",
      }),
    });
  },
};
